package org.jpro.modules.system.service.impl;

import org.jpro.modules.system.dao.RoleRepository;
import org.jpro.modules.system.entity.Role;
import org.jpro.modules.system.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <P>功能描述 : 角色service实现 </P>
 * <P>File name : RoleServiceImpl </P>
 * <P>Author : 王泽浩 </P>
 * <P>E-Mail : 1028625100@qq.com </P>
 * <P>Date : 2017/3/4 上午12:03</P>
 */
@Service
@Transactional(readOnly = true)
public class RoleServiceImpl implements IRoleService {

    @Autowired
    private RoleRepository roleRepository;

    @Override
    public Page<Role> search(PageRequest pageRequest) {
        return roleRepository.findAll(pageRequest);
    }

    @Override
    @Transactional
    public void save(Role role) {
        roleRepository.save(role);
    }

    @Override
    @Transactional
    public void delete(Integer id) {
        roleRepository.delete(id);
    }

    @Override
    @Transactional
    public Role get(Integer id) {
        return roleRepository.getOne(id);
    }
}
